//package wjh.congfig;
//
//import com.mchange.v2.c3p0.ComboPooledDataSource;
//
//import org.apache.commons.dbutils.QueryRunner;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.ComponentScan;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.PropertySource;
//
//import javax.sql.DataSource;
//import java.beans.PropertyVetoException;
//
///**
// * 功能
// * 作者：lyh
// * 日期：2024/9/5 14:10
// */
////声明当前类属于spring的配置类
//@Configuration
////开启包扫描
//@ComponentScan(basePackages = {"wjh"})
//@PropertySource({"classpath:db.properties"})
//public class SpringConfig {
//    //通过value注解读取属性配置文件的属性key 交给成员变量
//    @Value("${driverClass}")
//    private String driverClass;
//    @Value("${jdbcUrl}")
//    private String jdbcUrl;
//    @Value("${user}")
//    private String user;
//    @Value("${password}")
//    private String password;
//
//    //纯注解来配置
////    @Bean //Bean的默认id值 方法名称
////    public User user(){
////        User user = new User(731, "刘聪", "123");
////        return user;
////    }
////    基于配置类改造
//    @Bean
//    public DataSource dataSource() throws PropertyVetoException {
//        //创建c3p0连接池
//        ComboPooledDataSource dataSource = new ComboPooledDataSource();
//        dataSource.setDriverClass(driverClass);
//        dataSource.setJdbcUrl(jdbcUrl);
//        dataSource.setUser(user);
//        dataSource.setPassword(password);
//        return dataSource;
//    }
//
//    @Bean
//    public QueryRunner qr() throws PropertyVetoException {
//        return new QueryRunner(dataSource());
//    }
//}
